package com.fowo.api.pda.controller;

import com.fowo.api.common.model.R;
import com.fowo.api.controller.purchase.vo.inventoryTurnoverVo;
import com.fowo.api.entity.WarehouseBin;
import com.fowo.api.inventory.model.form.InventoryExchangeFormVo;
import com.fowo.api.pda.model.*;
import com.fowo.api.pda.service.PdaInventoryService;
import com.fowo.api.service.PositionInventoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "PDA库存查询")
@RequestMapping("/api/pda/inventory")
@RestController
public class PdaInventoryController {

    @Resource
    private PdaInventoryService pdaInventoryService;

    @Resource
    private PositionInventoryService positionInventoryService;

    @Operation(summary = "根据产品编码查询库存信息")
    @GetMapping("/product")
    public R<List<ProductInventoryVo>> getInventoryByProduct(InventoryBo search) throws Exception{
        return R.data(pdaInventoryService.getInventoryByProduct(search));
    }

    @Operation(summary = "根据仓位查询库存信息")
    @GetMapping("/bin")
    public R<WarehouseBinVo> getInventoryByBin(Long stockId,String storageBin){
        return R.data(pdaInventoryService.getInventoryByBin(stockId,storageBin));
    }


    @Operation(summary = "仓位转移")
    @PostMapping("/inventoryTransfer")
    public R<?> moveBin(@RequestBody PutawayVo model){
        return R.run(() -> pdaInventoryService.moveBin(model));
    }

}
